package com.zeroone.star.mongo.controller;

import com.zeroone.star.mongo.dto.MemberReadHistoryDTO;
import com.zeroone.star.mongo.service.MemberReadHistoryService;
import com.zeroone.star.mongo.vo.MemberReadHistoryVO;
import com.zeroone.star.project.vo.JsonVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 测试消息发布控制器
 * @Author lyx
 * @since 2024/11/8 21:54
 */

@RestController
@RequestMapping("mongo")
@Api(tags = "mongo")
public class MongoController {

    @Resource
    MemberReadHistoryService service;

    @ApiOperation("创建浏览历史记录")
    @PostMapping("history")
    public JsonVO<Integer> create(MemberReadHistoryDTO dto) {
        return JsonVO.success(service.save(dto));
    }

    @ApiOperation("删除浏览历史记录")
    @DeleteMapping("history")
    public JsonVO<Integer> remove(@RequestParam("ids") List<String> ids) {
        return JsonVO.success(service.remove(ids));
    }

    @ApiOperation("查看浏览历史记录")
    @GetMapping("history")
    public JsonVO<List<MemberReadHistoryVO>> find(Long memberId) {
        return JsonVO.success(service.list(memberId));
    }
}